package com.hainingtong.core.shiro.token;

import org.apache.shiro.authc.AuthenticationToken;

/**
 * token 帮助类，用于根据类型创建不同的token对象
 * 以后添加类型就统一在这里添加，无需修改controller里面的代码
 */
public class TokenUtil {
    public static AuthenticationToken createToken(String principal, String credentials, LoginType loginType) {
        switch (loginType) {
            case WxLogin:
                return new WxLoginToken(principal, credentials, loginType);
            case PhoneCode:
                return new PhoneCodeToken(principal, credentials, loginType);
            case EmailPassword:
                return new EmailPasswordToken(principal, credentials, loginType);
            case PhonePassword:
                return new PhonePasswordToken(principal, credentials, loginType);
            case UsernamePassword:
                return new CustomUsernamePasswordToken(principal, credentials, loginType);
        }
        return null;
    }
}
